package mvc;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

public class MainController implements Listener {
	
	protected MainModel model;
	protected MainView mainView;
	public ViewNewUser viewNewUser;
	public ViewLoadUser viewLoadUser;

	public MainController(MainView view){
		model = new MainModel();
		this.mainView = view;
		
	}

	@Override
	public void handleEvent(Event arg0) {
		switch (arg0.type){		
		case SWT.MouseUp:			
			break;
			
		case SWT.Selection:					
			if (arg0.widget.equals(mainView.loginUserItem)){	
				mainView.shell.setEnabled(false);
				viewLoadUser = new ViewLoadUser(this);				
			}
			if (arg0.widget.equals(viewNewUser.btnNewButton)){				
			}			
			break;			
			
		case SWT.Dispose:
			if (arg0.widget.equals(viewNewUser.shellNewUser)){			
				mainView.shell.setEnabled(true);
			}			
			if (arg0.widget.equals(viewLoadUser.shellLoadUser)){			
				mainView.shell.setEnabled(true);
			}
			break;
		}
	}		

	
}
